package com.hj.security.engine;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

import com.hj.security.domain.UpdateInfo;

import android.content.Context;

public class UpdateInfoService {
	private Context context;

	public UpdateInfoService(Context context) {
		this.context = context;
	}
	public UpdateInfo getUpdateInfo(int urlId) throws Exception{
		String path = context.getResources().getString(urlId);
		URL url = new URL(path);
		HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
		httpURLConnection.setConnectTimeout(500);//超时时间
		httpURLConnection.setRequestMethod("GET");//请求方式
		InputStream inputStream = httpURLConnection.getInputStream();
		return UpdateInfoParser.getUpdateInfo(inputStream);
	}
}
